 package com.wudi.estate.mapper.ownermanagement;

 import com.wudi.estate.bean.ownermanagement.Vehicle;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;

 import java.util.List;

@Mapper
public interface VehicleMapper {
    @Select("select * from vehicle")
    List<Vehicle> selectAll() throws Exception;

    @Select("select * from vehicle where id = #{id}")
    Vehicle selectById(Vehicle v) throws Exception;

    @Insert("insert into vehicle values (default,#{img},#{color},#{vcard},#{remark},#{createTime},#{pid},#{state})")
    void insert(Vehicle v) throws Exception;

    @Update("update vehicle set state = #{state} where id =#{id}")
    void prohibit(Vehicle v) throws Exception;
    @Update("update vehicle set img=#{img},color=#{color},vcard=#{vcard},remark=#{remark},create_time=#{createTime},pid=#{pid},vcard=#{vcard} ,state=#{state} where id =#{id}")
    void updateById(Vehicle v) throws Exception;
//    根据pid去查询车辆信息（parkingUsage用）
    @Select("select * from vehicle where pid = ${pId}")
    Vehicle selectByPid(long pId) throws Exception;

    @Select("select * from vehicle where vcard like '%${vcard}%'")
    List<Vehicle> selectByName(String vcard) throws Exception;
}
